import React from 'react'
import { useLocation, useParams } from 'react-router-dom';
import axios from 'axios';
import { useEffect, useState } from 'react'
type Props = {}

interface detailObjType {
    img1: string,
    [key: string]: any
}
export default function Detail({ }: Props) {
    const par = useParams<{ id: string }>()
    const loc = useLocation();
    const [detailobj, setdetailobj] = useState<detailObjType | {}>({})
    console.log(par)
    console.log(loc)
    useEffect(() => {
        // 请求详情页数据
        axios.get('http://47.94.148.165:3001/api/pro/detail/' + par.id).then(res => {
            console.log('res', res);
            setdetailobj(res.data.data)
        })

    }, [])

    return (
        <div>
            我是详情页
            <>
                <img src={(detailobj as detailObjType).img1} alt="" />
            </>
        </div>
    )
}